package com.icss.train_sys_back.mapper.train_manage;

import com.icss.train_sys_back.entity.SeatEntity;
import com.icss.train_sys_back.entity.train_manage.TrainCarriageEntity;
import com.icss.train_sys_back.entity.train_manage.TrainEntity;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @Author 小泽
 * @createTime 2025/9/25 16:36
 */
@Mapper
public interface TrainCarriageManageMapper {
    //车厢列表+分页+条件查询（如果有）
    List<TrainCarriageEntity> findListConditions(String trainNumber, String carriageNumber, Integer carriageType);

    //车厢添加
    boolean add(TrainCarriageEntity trainCarriage);

    //加载车辆的车辆号
    @Select("select * from t_train")
    List<TrainEntity> findTrainList();

    //车厢更新
    @Update("update t_train_carriage set train_number = #{trainNumber},carriage_number = #{carriageNumber} ," +
            "carriage_type = #{carriageType},seat_count = #{seatCount},no_seat_count = #{noSeatCount},create_time = now()" +
            "where carriage_id = #{carriageId}")
    boolean update(TrainCarriageEntity trainCarriage);

    //根据 id 删除车厢
    @Delete("delete from t_train_carriage where carriage_id = #{id}")
    boolean delete(Integer id);

    //获取所有车厢 类型
    @Select("select * from t_train_carriage")
    List<TrainCarriageEntity> getAllCarriageTypes();

    //添加座位
    void addSeats(List<SeatEntity> seatEntityList);

    //添加车厢
    void addCarriage(List<TrainCarriageEntity> carriageEntityList);
}
